﻿using System;
using System.Xml;
using System.Xml.Serialization;
using System.Drawing;
using rlTodayMakeSkin.Project.Attributes;


namespace rlTodayMakeSkin.Project.XmlElement
{
    /// <summary>
    /// represents a Calendar in skin
    /// </summary>
    public class rlCalendar : rlAbstractCalendar
    {
        /****************
         * FIELDS
         * *************/
        private int intRasterX;
        private int intRasterY;
        private Color clSaturday;
        private Color clSunday;
        private Color clToday;
        private string strTodayImage;
        


        /****************
         * CONSTRUCTORS
         * *************/
        public rlCalendar(XmlNode n, rlTodayProject p)
            : base(n, p)
        {
            if (listaAtt["saturdaycolor"] != null) clSaturday = GetColorFromRGB(listaAtt["saturdaycolor"].Value);
            if (listaAtt["sundaycolor"] != null) clSunday = GetColorFromRGB(listaAtt["sundaycolor"].Value);
            if (listaAtt["todaycolor"] != null) clToday = GetColorFromRGB(listaAtt["todaycolor"].Value);
            if (listaAtt["todayimage"] != null) strTodayImage = listaAtt["todayimage"].Value;
            if (listaAtt["rasterx"] != null) intRasterX = int.Parse(listaAtt["rasterx"].Value);
            if (listaAtt["rastery"] != null) intRasterY = int.Parse(listaAtt["rastery"].Value);
            strNome = "Calendar";

        }

        public rlCalendar(rlTodayProject p) : base(p)
        {
            strNome = "Calendar";
        }

        /// <summary>
        /// for the serialization
        /// </summary>
        public rlCalendar() { }


        /// <summary>
        /// Gets, sets width of a single day in the calendar
        /// </summary>
        [PropertyDescription("Gets, sets the width of a single day in the calendar", PropertyTypes.INTEGER)]
        [XmlAttribute("rasterx")]
        public int RasterX
        {
            get { return intRasterX; }
            set { intRasterX = value; }
        }

        /// <summary>
        /// Gets, sets height of a single day in the calendar
        /// </summary>
        [PropertyDescription("Gets, sets height of a single day in the calendar", PropertyTypes.INTEGER)]
        [XmlAttribute("rastery")]
        public int RasterY
        {
            get { return intRasterY; }
            set { intRasterY = value; }
        }

        /// <summary>
        /// Gets, sets color of saturday days in the calendar
        /// </summary>
        [PropertyDescription("Gets, sets color of saturday days in the calendar", PropertyTypes.COLOR)]
        [XmlIgnore()]
        public Color SaturdayColor
        {
            get { return clSaturday; }
            set { clSaturday = value; }
        }

        /// <summary>
        /// Returns a string that represents RGB value of the saturday days in the calendar
        /// </summary>
        [PropertyDescription("RGB value of the saturday days color", PropertyTypes.STRING, ReadOnlyProperty=true)]
        [XmlAttribute("saturdaycolor")]
        public string RGBSaturdayColor
        {
            get { return GetRGBFromColor(clSaturday); }
        }

        /// <summary>
        /// Gets, sets color of sunday days in the calendar
        /// </summary>
        [PropertyDescription("Gets, sets color of sunday days in the calendar", PropertyTypes.COLOR)]
        [XmlIgnore()]
        public Color SundayColor
        {
            get { return clSunday; }
            set { clSunday = value; }
        }

        /// <summary>
        /// Returns a string that represents RGB value of the sunday days in the calendar
        /// </summary>
        [PropertyDescription("RGB value of the sunday days color", ReadOnlyProperty=true)]
        [XmlAttribute("sundaycolor")]
        public string RGBSundayColor
        {
            get
            {
                return GetRGBFromColor(clSunday);
            }
        }

        /// <summary>
        /// Gets, sets filename of an image shown centered on the current day
        /// </summary>
        [PropertyDescription("Gets, sets filename of an image shown centered on the current day")]
        [XmlAttribute("todayimage")]
        public string TodayImage
        {
            get { return strTodayImage; }
            set { strTodayImage = value;}
        }

        public override void DrawElement(Graphics g)
        {
            DrawImage(g,"CalendarBig.png");
        }

        /******************
         PRIVATE MEMBERS
         *****************/

    }
}
